<?php $this->renderPartial('../common/_header');?>
<div class="container my-container">
    <div class="row">
        <div class="col col-lg-3">
            <?php $this->renderPartial('//common/'.($this->user ? 'menu' : 'menu_guest'));?>
        </div>
        <div class="col col-lg-9">

            <div class="page-header">
                <h2><?php echo $post->title?></h2>
            </div>

            <div class="well">
                <?php if($this->user->phone_main):?>
                    <div class="row">
                        <label class="col col-lg-2 control-label">Số điện thoại</label>
                        <div class="col col-lg-8"><?php echo $this->user->phone_main->phoneLabel?></div>
                    </div>
                    <?php endif?>
                <?php if($post->city):?>
                    <div class="row">
                        <label class="col col-lg-2 control-label">Thành phố</label>
                        <div class="col col-lg-8"><?php echo $post->city->name?></div>
                    </div>
                    <?php endif?>
                <?php if($post->district):?>
                    <div class="row">
                        <label class="col col-lg-2 control-label">Quận</label>
                        <div class="col col-lg-8"><?php echo $post->district->name?></div>
                    </div>
                    <?php endif?>
                <?php if($post->addressFull):?>
                    <div class="row">
                        <label class="col col-lg-2 control-label">Địa chi</label>
                        <div class="col col-lg-8"><?php echo $post->addressFull?></div>
                    </div>
                    <?php endif?>
                <?php if($post->typeLabel):?>
                    <div class="row">
                        <label class="col col-lg-2 control-label">Cần</label>
                        <div class="col col-lg-8"><?php echo $post->typeLabel?></div>
                    </div>
                    <?php endif?>
                <?php if($post->stateLabel):?>
                    <div class="row">
                        <label class="col col-lg-2 control-label">Tình trạng</label>
                        <div class="col col-lg-8"><?php echo $post->stateLabel?></div>
                    </div>
                    <?php endif?>
                <?php if($post->price):?>
                    <div class="row">
                        <label class="col col-lg-2 control-label">Giá</label>
                        <div class="col col-lg-8"><?php echo $post->priceLabel?></div>
                    </div>
                    <?php endif?>
                <div class="row">
                    <label class="col col-lg-2 control-label">Đăng lúc</label>
                    <div class="col col-lg-8"><?php echo $post->createdLabel?></div>
                </div>
                <div class="row">
                    <label class="col col-lg-2 control-label">Lượt xem</label>
                    <div class="col col-lg-8"><?php echo $post->viewLabel?></div>
                </div>
            </div>


            <div class="row margintop20">
                <div class="col col-lg-12">
                    <fieldset>
                        <legend>Nội dung</legend>
                        <?php echo $post->content?>
                    </fieldset>
                </div>
            </div>

            <?php if($post->show_map):?>
                <div class="row margintop20">
                    <div class="col col-lg-12">
                        <fieldset>
                            <legend>Bản đồ</legend>
                            <div id="map" class="well" style="width: 100%; height: 300px; margin: 0;">
                                <div style="color: #999999;padding-top: 110px;text-align: center;">
                                    <i class="icon-refresh icon-spin"></i> Tải bản đồ
                                </div>
                            </div> 
                        </fieldset>
                    </div>
                </div>
                <?php endif?>

            <?php if($post->image):?>
                <div class="row margintop20">
                    <div class="col col-lg-12">
                        <fieldset>
                            <legend>Ảnh đính kèm</legend>
                        </fieldset>

                        <div id="image-gallery">

                            <?php foreach($post->postImages as $image):?>
                                <span class="image-item">
                                    <a href="<?php echo $image->url?>" title="<?php echo $this->domain?>: <?php echo CHtml::encode($post->title)?>" download="<?php echo $image->image?>" data-gallery><img src="<?php echo $image->getUrl('small')?>" alt="<?php echo $this->domain?>: <?php echo CHtml::encode($post->title)?>"></a>
                                </span>
                                <?php endforeach?>

                        </div>
                    </div>
                </div>
                <?php endif?>


        </div>
    </div>

</div>
<?php if($post->image):?>
    <div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" data-filter=":even">
        <div class="slides"></div>
        <h3 class="title"></h3>
        <a class="prev">‹</a>
        <a class="next">›</a>
        <a class="close">×</a>
        <a class="play-pause"></a>
        <ol class="indicator"></ol>
    </div>
    <link rel="stylesheet" href="/files/js/blueimp/jquery.gallery/css/blueimp-gallery.min.css">
    <script src="/files/js/blueimp/jquery.gallery/js/jquery.blueimp-gallery.min.js"></script>
    <?php endif?>

<?php if($post->show_map):?>
    <script type="text/javascript" src="<?php echo $this->googleMapURI?>"></script>
    <script type="text/javascript" src="/files/js/google-maps-utility-library-v3/infobox/src/infobox_packed.js"></script> 
    <script>var infoBoxHtml = '<b><?php echo $post->title?></b><br><?php echo $post->addressFull?>';</script>
    <?php endif?>

<script type="text/javascript" src="<?php echo $this->themeUrl?>/files/js/hangve/post_view.js"></script>

<?php if($post->show_map):?>
    <script>google_map('<?php echo $post->latlng?>');</script>
    <?php endif?> 







